<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>change user's profile</title>
<link type="text/css" href="JSP/css/style.css" rel="stylesheet"></link>
</head>
<script type="text/javascript">
	function check_fields() {
		var field1 = document.getElementById('pwd');
		var field2 = document.getElementById('repwd');
		if (field1.value == "" || field2.value == "") {
			alert('Password fields can not be empty!');
			return false;
		}

		if (field1.value !== field2.value) {
			alert('Two passwords you entered does not match. Please try again!');
			return false;
		} else {
			return true;
		}
	}
</script>
<%@include file="../checkSession.jsp"%>
<%@page import="model.UserInfo"%>
<body>
	<div id="wrap">
		<%@include file="adminHeader.jsp"%>
		<font size="3" face="verdana" color="orange">Change Profile</font>
		<div class="center_content">
			<div class="right_content">
				<%
					UserInfo user = (UserInfo) request.getAttribute("UserAcc");
					if (user == null) {
						out.println("NULL");
					} else {
				%>
				<form name="input" action="./ServletUpdateUser" method="post">
					<table>
						<tr>
							<td align="right">Username:</td>
							<td><input type="text" name="user" readonly="readonly"
								value=<%=user.username%>></td>
						<tr>
							<td align="right">Account Status:</td>
							<td><select name="status">
									<%
										String s11, s12;
											s11 = s12 = "";
											if (user.status.equals("LOCK"))
												s11 = "selected";
											else
												s12 = "selected";
									%>
									<option value="LOCK" <%=s11%>>LOCK</option>
									<option value="UNLOCK" <%=s12%>>UNLOCK</option>
							</select></td>
						</tr>
						<tr>
							<td align="right">New Password:</td>
							<td><input type="password" name="pwd" id="pwd"></td>
						<tr>
							<td align="right">Retypepass:</td>
							<td><input type="password" name="repwd" id="repwd"></td>
						</tr>
						<tr>
							<td align="right">Quota:</td>
							<td><select name="quota">
									<%
										String s1, s2, s3, s4;
											s1 = s2 = s3 = s4 = "";
											if (user.quota.equals("10M"))
												s1 = "selected";
											else if (user.quota.equals("100M"))
												s2 = "selected";
											else if (user.quota.equals("500M"))
												s3 = "selected";
											else
												s4 = "selected";
									%>
									<option value="10M" <%=s1%>>10M</option>
									<option value="100M" <%=s2%>>100M</option>
									<option value="500M" <%=s3%>>500M</option>
									<option value="UNLIMITED" <%=s4%>>UNLIMITED</option>
							</select></td>
						</tr>
						<tr>
							<td align="right">Role:</td>
							<td><input type="text" name="role" readonly="readonly"
								value=<%=user.role%>></td>
						<tr>
							<td align="right">Profile:</td>
							<td><input type="text" name="profile" readonly="readonly"
								value=<%=user.profile%>></td>
						</tr>
					</table>
					<input type="submit" onclick="return check_fields(); return true;"
						value="Submit" /><br>
				</form>
				<%
					}
				%>
			</div>
		</div>
	</div>
</body>
</html>